{include file="public/meta"}
<article class="page-container">
	<form class="form form-horizontal" id="form-admin-add" method="post">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>管理员名称：</label>
			<div class="formControls col-xs-8 col-sm-9">
				{empty name="one"}
					<input type="text" class="input-text" value="{$one.username}" placeholder="" id="adminName" name="username">
				{else/}
				<input type="text" class="input-text" value="" placeholder="请输入您要修改的名称" id="adminNames" name="username">
				{/empty}
			</div>
		</div>

		{empty name="one"}
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>密码：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="password" class="input-text" autocomplete="off"
					   value="" placeholder="密码" id="password" name="password">
			</div>
		</div>

		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>是否启用：</label>
			<div class="formControls col-xs-8 col-sm-9 skin-minimal">
				<div class="radio-box">
					<input name="status" type="radio" id="sex-1" checked value="1">
					<label for="sex-1">启用</label>
				</div>
				<div class="radio-box">
					<input type="radio" id="sex-2" name="status" value="2">
					<label for="sex-2">禁用</label>
				</div>
			</div>
		</div>
		{/empty}
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">角色：</label>
			<div class="formControls col-xs-8 col-sm-9"> <span class="select-box" style="width:150px;">
			<select class="select" name="adminRole" size="1">
				{volist name="result" id="v"}
					<option value="{$v.id}" {$v.id == $one.group_id ? 'selected' : ''}>{$v.groupname}</option>
				{/volist}
			</select>
			</span> </div>
		</div>
		<!--<div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">备注：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <textarea name="" cols="" rows="" class="textarea"  placeholder="说点什么...100个字符以内" dragonfly="true" onKeyUp="$.Huitextarealength(this,100)"></textarea>
                <p class="textarea-numberbar"><em class="textarea-length">0</em>/100</p>
            </div>
        </div>-->
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<input hidden value="{$one.id}" name="id">
				<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
</article>

<!--_footer 作为公共模版分离出去-->
{include file="public/_footer"}
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__STATIC__/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="__STATIC__/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="__STATIC__/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript">
    $(function(){
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $("#form-admin-add").validate({
            rules:{
                username:{
                    required:true,
                    minlength:4,
                    maxlength:16
                },
                password:{
                    required:true,
                },
                adminRole:{
                    required:true,
                },
            },

            submitHandler:function(form)
			{
				var data = $(form).serialize();  //获取表单里的数据
                url = "{:url('admin/admin')}";
				$.post(url,data,function(result)
				{
				    if(result.code == 1)   //添加成功
				    {
                        layer.msg(result.msg,{icon:1,time:2000});
                        setInterval("closeWindow()",2000);
					}else{
                        layer.msg(result.msg,{icon:5,time:2000});
					}
				},'JSON')
            }
        });
    });
	function closeWindow()
	{
        var index = parent.layer.getFrameIndex(window.name);
        window.parent.location.reload();
	}
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>